// components/EnglishTyping.module.scss
@charset "UTF-8";

// ======================
// 主题变量定义
// ======================
$primary: #4caf50; /* 主色 - 森林绿 */
$success: $primary; /* 成功色 */
$error: #ff4444; /* 错误色 */
$text-dark: #212121; /* 深文本色 */
$text-light: #666; /* 浅文本色 */
$bg-light: #f8f9fa; /* 浅色背景 */
$bg-white: #ffffff; /* 白色背景 */
$shadow-light: 0 2px 15px rgba(0, 0, 0, 0.05); /* 浅阴影 */
$shadow-medium: 0 8px 30px rgba(0, 0, 0, 0.1); /* 中阴影 */
$input-padding: 0.3rem 0.6rem; /* 输入框内边距 */

// ======================
// 混合器定义（Mixin）
// ======================
// 衬线字体混合器
@mixin font-serif($size, $color) {
  font-family: "Times New Roman", serif;
  font-size: $size;
  color: $color;
  line-height: 1.4;
}

// 无衬线字体混合器
@mixin font-sans($size, $color) {
  font-family: "Microsoft YaHei", sans-serif;
  font-size: $size;
  color: $color;
  line-height: 1.6;
}

// 脉冲动画混合器
@mixin pulse-animation {
  animation: pulse 1.2s infinite;
}

// 抖动动画混合器
@mixin shake-animation {
  animation: shake 0.5s ease-out;
}

// 渐显动画
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

// 脉冲动画
@keyframes pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba($primary, 0.2);
  }
  70% {
    transform: scale(1.03);
    box-shadow: 0 0 0 10px rgba($primary, 0);
  }
  100% {
    transform: scale(1);
  }
}

// 抖动动画
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

// ======================
// 主容器样式
// ======================
.EnglishTyping {
  min-height: 100vh;
  background: $bg-light;
  padding: 2rem 1rem;
  @include font-sans(16px, $text-light);
  display: flex;
  flex-direction: column;
  align-items: center;

  // 标题样式
  .title {
    @include font-serif(3rem, $primary);
    text-align: center;
    margin: 1rem 0 3rem;
    font-weight: 700;
    letter-spacing: 1px;
    background: linear-gradient(45deg, $primary, #2e7d32);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: fadeIn 0.8s ease-out;

    // 标题下划线
    &::after {
      content: "";
      display: block;
      width: 60px;
      height: 3px;
      background: $primary;
      margin: 0.5rem auto;
      border-radius: 1px;
    }
  }
}

// ======================
// 核心功能区样式
// ======================
.content {
  max-width: 1200px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3rem;
}

// 进度条
.progress-container {
  width: 100%;
  max-width: 70%;
  height: 6px;
  background: #e0e0e0;
  border-radius: 3px;
  overflow: hidden;

  .progress {
    height: 100%;
    background: $primary;
    width: 0%;
    transition: width 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: 0 1px 3px rgba($primary, 0.3);
  }
}

// 句子卡片
.sentence-card {
  background: $bg-white;
  padding: 2rem 3rem;
  border-radius: 18px;
  box-shadow: $shadow-medium;
  text-align: center;
  width: 100%;
  max-width: 800px;

  // 鼠标悬停效果
  &:hover {
    transform: translateY(-5px);
    box-shadow: $shadow-medium;
  }

  .sentence {
    @include font-serif(1.4rem, $text-dark);
    line-height: 1.8;

    .word {
      display: inline-flex;
      align-items: center;
      gap: 0.4rem;
      margin: 0.6rem 0;

      .space-input {
        @include font-serif(1.1rem, $text-dark);
        padding: $input-padding;
        border: 2px solid #e0e0e0;
        border-radius: 6px;
        background: transparent;
        text-align: center;
        min-width: 20px;
        transition: all 0.3s ease;

        // 聚焦状态
        &:focus {
          border-color: $primary;
          box-shadow: 0 0 10px rgba($primary, 0.2);
          transform: translateY(-1px);
        }

        // 正确状态
        &.correct {
          @include pulse-animation;
          border-color: $success;
          background: $success;
          color: $bg-white;
        }

        // 错误状态
        &.error {
          @include shake-animation;
          border-color: $error;
        }
      }
    }
  }
}

// ======================
// 底部提示栏
// ======================
.hint-card {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: $bg-white;
  padding: 1.2rem 2rem;
  border-radius: 12px;
  box-shadow: $shadow-light;
  width: 90%;
  max-width: 800px;
  z-index: 10;

  .hint {
    @include font-sans(1rem, $text-light);

    .prefix {
      color: $primary;
      font-weight: 600;
      margin-right: 0.6rem;
    }
  }
}

// ======================
// 统计信息栏
// ======================
.stats-card {
  position: fixed;
  top: 2rem;
  right: 2rem;
  background: $bg-white;
  padding: 1.2rem 1.5rem;
  border-radius: 12px;
  box-shadow: $shadow-light;
  backdrop-filter: blur(5px);

  .stat-item {
    @include font-sans(0.9rem, $text-dark);
    margin: 0.7rem 0;

    .value {
      color: $primary;
      font-weight: 700;
      font-size: 1.1rem;
    }
  }
}

// ======================
// 操作按钮
// ======================
.controls {
  display: flex;
  gap: 1.2rem;
  margin: 2rem 0;

  .btn {
    padding: 0.8rem 2.2rem;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    @include font-serif(0.9rem, $bg-white);
    font-weight: 600;
    letter-spacing: 0.5px;

    // 主按钮（绿色）
    &.primary {
      background: linear-gradient(135deg, $primary, #2e7d32);
      box-shadow: 0 4px 15px rgba($primary, 0.3);

      &:hover {
        box-shadow: 0 6px 20px rgba($primary, 0.4);
        transform: translateY(-2px);
      }
    }

    // 次按钮（灰色）
    &.secondary {
      color: $text-dark;
      background: $bg-white;
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);

      &:hover {
        background: #f0f0f0;
      }
    }
  }
}

// ======================
// 反馈提示
// ======================
.feedback {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 1.5rem 2rem;
  border-radius: 10px;
  @include font-serif(1.1rem, $bg-white);
  font-weight: 600;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease;

  // 成功反馈
  &.success {
    background: rgba($success, 0.9);
    box-shadow: 0 0 20px rgba($success, 0.3);
  }

  // 错误反馈
  &.error {
    background: rgba($error, 0.9);
    box-shadow: 0 0 20px rgba($error, 0.3);
  }

  // 显示状态
  &.show {
    opacity: 1;
  }
}
